﻿using System.Collections.Generic;
using SpecFlowTfsLinker.Entities;

namespace SpecFlowTfsLinker.Printer
{
    public class TestCasePrinter
    {
        public TestCasePrinter(TestCase testCase)
        {
            DisplayName = testCase.Name;
            Given = new List<StatementPrinter>();
            When = new List<StatementPrinter>();
            Then = new List<StatementPrinter>();

            Initialize(testCase.Given, Given);
            Initialize(testCase.When, When);
            Initialize(testCase.Then, Then);
        }

        public string DisplayName { get; set; }
        public List<StatementPrinter> Given { get; set; }
        public List<StatementPrinter> When { get; set; }
        public List<StatementPrinter> Then { get; set; }
        public List<StatementPrinter> GivenWhenThen
        {
            get
            {
                var givenWhenThen = new List<StatementPrinter>();
                givenWhenThen.AddRange(Given);
                givenWhenThen.AddRange(When);
                givenWhenThen.AddRange(Then);
                return givenWhenThen;
            }
        }

        private static void Initialize(List<Statement> statements, List<StatementPrinter> liste)
        {
            statements.ForEach(statement => liste.Add(new StatementPrinter(statement, statement.Type)));
        }

    }
}